﻿using ReflectionStudio.Core.Events;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for EditEventWindow.xaml
    /// </summary>
    public partial class TKSLEIST
    {

        #region ==ABF===========
        public static readonly DependencyProperty ABFProperty = DependencyProperty.Register("ABF",
            typeof(string), typeof(TKSLEIST),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABFChanged));
        public string ABF
        {
            get
            {
                return (string)GetValue(ABFProperty);
            }
            set
            {
                SetValue(ABFProperty, value);
                ((VKSLEIST)MV).LOADABF(value);
            }
        }
        private static void OnABFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TKSLEIST;
            if (src != null)
            {
                src.ABF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==FTAUTOSPLIT===========
        public static readonly DependencyProperty FTAUTOSPLITProperty = DependencyProperty.Register("FTAUTOSPLIT",
            typeof(bool), typeof(TKSLEIST),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTAUTOSPLITChanged));
        public bool FTAUTOSPLIT
        {
            get
            {
                return (bool)GetValue(FTAUTOSPLITProperty);
            }
            set
            {
                SetValue(FTAUTOSPLITProperty, value);
            }
        }
        private static void OnFTAUTOSPLITChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as TKSLEIST;
            if (src != null)
            {
                src.FTAUTOSPLIT = (bool)e.NewValue;
            }
        }
        #endregion

        public TKSLEIST()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VKSLEIST();
            DataContext = MV;
            IsMasterFromMV = true;
            InitializeComponent();

        }
        public override void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, System.EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
                return;
            if (FTAUTOSPLIT)
            {
                MessageInfo msg = new MessageInfo();
                msg.Sender = this.RUNID;
                msg.MSGTYPE = "RESPLIT";
                msg.ACTION = "RESPLIT";
                msg.KRS = dwMaster["KSLAUFKRS"].ToString();
                msg.LFD = dwMaster["KSLAUFLFD"].ToString();
                msg.POS = dwMaster["KSLAUFPOS"].ToString();
                msg.P1 = dwMaster["KSLAFOLGE"].ToString();
                msg.P2 = ABF;
                DataSet Set = new DataSet();
                Set.Merge(TBMain);
                msg.Set = Set;
                VICC_WFEVENTS.SVWF.CheckEvents("UIMESSAGE", null, "", msg);
            }
        }
    }
}
